package com.system.menu;

import com.system.service.Login;

import java.util.Scanner;

public class LoginMenu {
    public final static Scanner sc = new Scanner(System.in);
    private final Login login = new Login();
    private final static MainMenu mu = new MainMenu();  // 套娃
    private final UI ui = new UI();

    // 主菜单
    public void menu() {
        while (true) {
            ui.loginUI();
            int opt;
            if (sc.hasNextInt()) {
                opt = sc.nextInt();
            } else {
                System.out.println("输入错误，请输入(1-3)。");
                sc.next();
                continue;
            }
            switch (opt) {
                case 1:
                    String enterAccessForUp = login.login();
                    mu.mainMenu(enterAccessForUp);
                    return;
                case 2:
                    String enterAccessForIn = login.scannerSignup();
                    mu.mainMenu(enterAccessForIn);
                    return;
                case 3:
                    boolean exit = mu.continue_menu();
                    if (exit) {
                        return;
                    }
                    System.out.println("请重新选择：");
                    continue;
                default:
                    System.out.println("输入错误—_—");
                    break;
            }
        }
    }
}
